package com.kefu.call.service;

import com.kefu.common.util.JacksonUtil;
import com.kefu.sys.model.SysTenant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.kefu.common.service.AbstractKefuService;
import com.kefu.call.mapper.CallCompanyMapper;
import com.kefu.call.model.CallCompany;
import com.kefu.call.service.CallCompanyService;

import javax.annotation.Resource;
import java.util.Objects;

@Service
public class CallCompanyService extends AbstractKefuService<CallCompany> {
    @Resource
    protected CallCompanyMapper callCompanyMapper;

    public void initCompany(SysTenant sysTenant) {
                CallCompany callCompany = new CallCompany();
        callCompany.setFid(sysTenant.getTenantId());
        callCompany.setFName(sysTenant.getTenantName());
        callCompany.setFAsrcount(((Objects.isNull(sysTenant.getHelperInfoCount()) ? 0 : sysTenant.getHelperInfoCount()) * 2)
                + (Objects.isNull(sysTenant.getRobotCallCount()) ? 0 : sysTenant.getRobotCallCount()));
        callCompanyMapper.insert(callCompany);
        logger.info("初始化呼叫租户信息:{}", JacksonUtil.toString(callCompany));
    }
}